package com.kmist.xiakexing.main.impl;

import com.kmist.xiakexing.R;
import com.kmist.xiakexing.tools.SaveTool;

public class Hero {

    private static Hero instance = new Hero();


    public static Hero getInstance() {
        return instance;
    }

    public Hero(){
        loadHero();
    }

    public void createPlayer(String name, String gender){
        mName = name;
        mGender = gender;
        mHp = 100;
        mMp = 30;
        mSpeed = 100;
        mDefence = 20;
        mSpeed = 100;
        mLevel = 1;
        mEvolution = 0;
        mJinbi = 0;
        mIcon = R.mipmap.pic_02;

        saveHero();
    }

    public void saveHero() {
        SaveTool.putString("UUID","123456789");
        SaveTool.putInt("Icon", mIcon);
        SaveTool.putString("Name",mName);
        SaveTool.putString("Gender",mGender);
        SaveTool.putInt("Hp",mHp);
        SaveTool.putInt("Mp",mMp);
        SaveTool.putInt("Attach",mAttach);
        SaveTool.putInt("Defence",mDefence);
        SaveTool.putInt("Speed",mSpeed);
        SaveTool.putInt("Level",mLevel);
        SaveTool.putInt("Evolution",mEvolution);
        SaveTool.putInt("Jinbi",mJinbi);
    }

    public void loadHero() {

        try{
            UUID = SaveTool.getString("UUID","none");
            if (!UUID.equals("none")){
                mIcon = SaveTool.getInt("Icon", 0);
                mName = SaveTool.getString("Name","");
                mGender = SaveTool.getString("Gender","");
                mHp = SaveTool.getInt("Hp",100);
                mMp = SaveTool.getInt("Mp", 100);
                mAttach = SaveTool.getInt("Attach", 100);
                mDefence = SaveTool.getInt("Defence", 100);
                mSpeed = SaveTool.getInt("Speed", 100);
                mLevel = SaveTool.getInt("Level", 100);
                mEvolution = SaveTool.getInt("Evolution", 100);
                mJinbi = SaveTool.getInt("Jinbi", 100);
                mCurHp = mHp;
                mCurMp = mMp;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String query_respect()
    {
        if(mGender.equals("woman")){
            return "小姑娘";
        }
        return "小伙子";
    }


    public int getNextEvolution(){
        return mLevel*10 + 356 * mLevel;
    }
    public String UUID;
    public int mIcon;
    public String mName;
    public String mGender;
    public int mHp;
    public int mMp;
    public int mAttach;
    public int mDefence;
    public int mSpeed;
    public int mLevel;
    public int mEvolution;
    public int mCurHp;
    public int mCurMp;
    public int mJinbi;
}
